// @File:           RedisAuthPlugin.h
// @ProjectName:    mosquitto_auth_plugin
// @Description:    ${description}
// @Author:         wujehy
// @Email:          wujehy@qq.com
// @Time:           2021-03-16 14:43

#ifndef MOSQUITTO_AUTH_PLUGIN_REDISAUTHPLUGIN_H
#define MOSQUITTO_AUTH_PLUGIN_REDISAUTHPLUGIN_H


#include <AuthPluginInterface.h>
/// 这是一个失误的提交，如果有兴趣 你们自行完善
/// 参考 SqliteAuth 即可
class RedisTool;
class RedisAuthPlugin : public AuthPluginInterface{
private:
    RedisTool *redisTool = nullptr;
public:
    void init() override;

    virtual ~RedisAuthPlugin();

    int checkUser(const std::string &username, const std::string &password) override;

    int getPskKey(mosquitto *client, const char *hint, const char *identity, char *key, int max_key_len) override;

    int checkAcl(mosquitto *client, ACLTypeEnum access, const mosquitto_acl_msg *msg) override;

    int cleanupSecurity(mosquitto_opt *auth_opts, int auth_opts_count, bool reload) override;

    int initSecurity(mosquitto_opt *auth_opts, int auth_opts_count, bool reload) override;
};


#endif //MOSQUITTO_AUTH_PLUGIN_REDISAUTHPLUGIN_H
